<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ProductGroup extends Model
{
    protected $guarded = ['id'];

    protected $appends = ['total_num'];  // 当前总的拼购数


    public function getTotalNumAttribute()
    {
    	$where['product_group_id'] = $this->id;
    	$where['status'] = 1;
    	return UserGroupbuy::where($where)->count();
    }
    
}
